#include <QtOpenGL/QGLWidget>
#include <QtGui/QApplication>
#include <QtDeclarative>
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeEngine>

#include <QtCore/QLocale>
#include <QtCore/QTranslator>

#include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN

#include "qmlapplicationviewer.h"
#include "rosyama/rosyama.h"
#include "rosyama/gconfitemqmlproxy.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());

    QTranslator translatorDefault;
    // Add fallback translator
    if (translatorDefault.load("rosyama", "/usr/share/l10n/meegotouch/")) {
        app->installTranslator(&translatorDefault);
    }
    QTranslator translatorLocal;
    if (translatorLocal.load("rosyama_" + QLocale::system().name(), "/usr/share/l10n/meegotouch/")) {
        app->installTranslator(&translatorLocal);
    }

    viewer->setViewport(new QGLWidget());
    viewer->rootContext()->setContextProperty("rosYama", new RosYama);

    qmlRegisterType<GConfItemQmlProxy>("MeeGoSettings", 1, 0, "GConfItem");

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer->setMainQmlFile(QLatin1String("qml/RosYama/main.qml"));
    viewer->showExpanded();

    return app->exec();
}
